home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 1999 #2 / Amiga Plus CD - 1999 - No. 2.iso / System-Boost / Workbench / ToolManager / Source / Converter / exec.c < prev    next >
C/C++ Source or Header  |  1998-06-17  |  4KB  |  114 lines

  1. /*
  2.  * exec.c  V3.1
  3.  *
  4.  * ToolManager old preferences converter for Exec Objects
  5.  *
  6.  * Copyright (C) 1990-98 Stefan Becker
  7.  *
  8.  * This source code is for educational purposes only. You may study it
  9.  * and copy ideas or algorithms from it for your own projects. It is
  10.  * not allowed to use any of the source codes (in full or in parts)
  11.  * in other programs. Especially it is not allowed to create variants
  12.  * of ToolManager or ToolManager-like programs from this source code.
  13.  *
  14.  */
  15.  
  16. #include "converter.h"
  17.  
  18. /* Local data */
  19. static struct MinList       IDList;
  20. static struct ExecDATAChunk edc;
  21.  
  22. /* Old Prefs stuff */
  23. struct ExecPrefsObject {
  24.                         ULONG epo_StringBits;
  25.                         ULONG epo_Flags;
  26.                         ULONG epo_Delay;
  27.                         ULONG epo_Stack;
  28.                         UWORD epo_ExecType;
  29.                         WORD  epo_Priority;
  30.                        };
  31. #define EXPO_NAME     (1L << 0)
  32. #define EXPO_COMMAND  (1L << 1)
  33. #define EXPO_CURDIR   (1L << 2)
  34. #define EXPO_HOTKEY   (1L << 3)
  35. #define EXPO_OUTPUT   (1L << 4)
  36. #define EXPO_PATH     (1L << 5)
  37. #define EXPO_PSCREEN  (1L << 6)
  38. #define EXPOF_ARGS    (1L << 0)
  39. #define EXPOF_TOFRONT (1L << 1)
  40.  
  41. /* Initialize Exec ID list */
  42. void InitExecIDList(void)
  43. {
  44.  NewList((struct List *) &IDList);
  45. }
  46.  
  47. /* Free Exec ID list */
  48. void FreeExecIDList(void)
  49. {
  50.  FreeIDList(&IDList);
  51. }
  52.  
  53. /* Find ID to corresponding Exec name */
  54. ULONG FindExecID(const char *name)
  55. {
  56.  return(FindIDInList(&IDList, name));
  57. }
  58.  
  59. /* Conversion routine */
  60. #undef  DEBUGFUNCTION
  61. #define DEBUGFUNCTION ConvertExecConfig
  62. BOOL ConvertExecConfig(void *chunk, struct IFFHandle *iffh, ULONG id)
  63. {
  64.  struct ExecPrefsObject *epo = chunk;
  65.  char                   *s   = (char *) (epo + 1);
  66.  BOOL                    rc  = FALSE;
  67.  
  68.  EXEC_LOG(LOG3(Entry, "Chunk 0x%08lx IFF Handle 0x%08lx ID 0x%08lx",
  69.                chunk, iffh, id))
  70.  
  71.  /* Get name to create ID list entry */
  72.  if ((epo->epo_StringBits & EXPO_NAME) && AddIDToList(&IDList, s, id)) {
  73.  
  74.   /* Copy fixed data */
  75.   edc.edc_Standard.sdc_ID    = id;
  76.   edc.edc_Standard.sdc_Flags = 0;
  77.   edc.edc_ExecType           = epo->epo_ExecType;
  78.   edc.edc_Priority           = epo->epo_Priority;
  79.   edc.edc_Stack              = epo->epo_Stack;
  80.  
  81.   /* Copy flags */
  82.   if (epo->epo_Flags & EXPOF_ARGS)    edc.edc_Standard.sdc_Flags
  83.                                         = DATA_EXECF_ARGUMENTS;
  84.   if (epo->epo_Flags & EXPOF_TOFRONT) edc.edc_Standard.sdc_Flags
  85.                                        |= DATA_EXECF_TOFRONT;
  86.  
  87.   /* Create new config entry */
  88.   rc = (PushChunk(iffh, ID_TMEX, ID_FORM, IFFSIZE_UNKNOWN) == 0) &&
  89.        (PushChunk(iffh, 0,       ID_DATA, IFFSIZE_UNKNOWN) == 0) &&
  90.        (WriteChunkBytes(iffh, &edc, sizeof(struct ExecDATAChunk))
  91.          == sizeof(struct ExecDATAChunk)) &&
  92.        (PopChunk(iffh) == 0) &&
  93.        (((epo->epo_StringBits & EXPO_NAME)    == 0) ||
  94.         (s = ConvertConfigString(s, iffh, ID_NAME))) &&
  95.        (((epo->epo_StringBits & EXPO_COMMAND) == 0) ||
  96.         (s = ConvertConfigString(s, iffh, ID_CMND))) &&
  97.        (((epo->epo_StringBits & EXPO_CURDIR)  == 0) ||
  98.         (s = ConvertConfigString(s, iffh, ID_CDIR))) &&
  99.        (((epo->epo_StringBits & EXPO_HOTKEY)  == 0) ||
  100.         (s = ConvertConfigString(s, iffh, ID_HKEY))) &&
  101.        (((epo->epo_StringBits & EXPO_OUTPUT)  == 0) ||
  102.         (s = ConvertConfigString(s, iffh, ID_OUTP))) &&
  103.        (((epo->epo_StringBits & EXPO_PATH)    == 0) ||
  104.         (s = ConvertConfigString(s, iffh, ID_PATH))) &&
  105.        (((epo->epo_StringBits & EXPO_PSCREEN) == 0) ||
  106.         (s = ConvertConfigString(s, iffh, ID_PSCR))) &&
  107.        (PopChunk(iffh) == 0)  ;
  108.  }
  109.  
  110.  EXEC_LOG(LOG1(Result, "%ld", rc))
  111.  
  112.  return(rc);
  113. }
  114.